<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1>8.html</h1>
  <button onclick="save()">save</button>
  <button onclick="read()">read</button>
  <script>
    function save() {
      document.cookie = "username=jack";
      document.cookie = "age=20";
    }

    function read() {
      console.log(document.cookie);  // username=jack; age=20
    }
  </script>
</body>

</html>